home *** CD-ROM | disk | FTP | other *** search
- Path: news.interlog.com!news
- From: cjohnson@interlog.com (Colin Johnson)
- Newsgroups: comp.lang.c++
- Subject: Re: Q: C++ read comma delim. text file & parse How?
- Date: Fri, 12 Apr 1996 05:15:57 GMT
- Organization: InterLog Internet Services
- Message-ID: <4kkoug$ks7@steel.interlog.com>
- References: <316be5bd.148077@news.fix.net>
- NNTP-Posting-Host: ip94-139.tor.interlog.com
- X-Newsreader: Forte Free Agent 1.0.82
-
- ryost@fix.net (Ron Yost) wrote:
-
- >Hi all,
- >I'm new to C++ (BC++ 4.52) and have old 'legacy' prg I need to port to C++.
- >I have ascii text files that serve as 'look up tables' for conversion routines,
- >to re-map (transpose) MIDI note numbers in a standard MIDI song file, and need
- >to read in comma delimited data and ignore comments after each line.
-
- >They're organized like this:
-
- >** MIDIMAP DATA ** < Header; to make sure file is correct.
- >144,56,145,78 comments <Want to read the 4 numbers in each row
- >145,34,144,45 comments <and parse the documentary comments
- >145,78,146,78 comments <after the rows. The comments are 35 chars max.
- >146,34,145,56 comments <The data represents channel, note number.
-
- >The files are 96 rows long, with four columns of numbers. I know I'll have to
- >convert the numbers from text to real numbers. These are to be read into 4
- >separate arrays, which will use the same index.
-
- >Each row represents one MIDI note;
- >First two numbers are an existing MIDI channel number and note number, say
- >144,56.
- >Second two numbers are what to change that to, say 145,78
-
- >This came from GFA Basic on an Atari ST, and I used the RIGHT$ function in basic
- >to parse the comments, but how in C++?? Sorry if this seems simple and stupid!!
-
- >Any help would be appreciated! THANKS a bunch!
-
- >Ron Yost <ryost@fix.net>
- >Paso Robles, CA
-
- I would suggest taking advantage of the strcspn function. This will return the
- length of the leftmost substring that does not have the letters specified, in
- your case it looks like a space. You could then copy this into another string.
-
- Good Luck.
-
- Colin Johnson
- ---------------------------------------------------------------
- Write a program so that an idiot can use it and only idiots will
- want to use it.
-
-